#include <iostream>
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <stdlib.h>
#include <regex>
#include <string>
#include <cstring>
#include <unistd.h>
#include <typeinfo>
#include <sstream>
#include <chrono>
// #include "filestream.cpp"
#include "sqlite3.cpp"

using namespace std;
using json=nlohmann::json;


string milliseconds()
{
    auto now        = std::chrono::system_clock::now();
    auto now_ms     = std::chrono::time_point_cast<std::chrono::milliseconds>(now);
    auto value      = now_ms.time_since_epoch().count();
    string str_time =(to_string(value)).substr(10,-1);
    return str_time;
}

int main(int argc, char const *argv[])
{
	const char* path="milliseconds.json";
	string ms;
	json js;

	while(1)
	{
		ms 	=milliseconds();
		js["ms"]=ms;
		string tms=js.dump();
		// file_put_contents(path, tms);
		string sql="UPDATE stime SET ctime='"+tms+"' where id=2;";
		sqlite3_idu(sql);
		sleep(1);
	}
	
	return 0;
}